/**
 * FileName: ResponseUtils
 * Author: zlz
 * CreatedDate: 2025/3/3 16:51:57
 * Description:
 * Version: 1.0.0
 */
package com.zlz.parent.basic.springboot.starter.utils;

import com.alibaba.fastjson.JSON;
import com.zlz.base.entity.response.ResultSet;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.server.reactive.ServerHttpResponse;
import reactor.core.publisher.Mono;

/**
 * @author zlz
 * @date 2025/3/3 16:51:57
 * @description
 */
public class ResponseUtils {

    public static <T> Mono<Void> writeSuccess(ServerHttpResponse response, ResultSet<T> data) {
        byte[] bytes = JSON.toJSONBytes(data);
        DataBuffer buffer = response.bufferFactory().wrap(bytes);
        return response.writeWith(Mono.just(buffer));
    }
}
